#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSystemTrayIcon>

class Configuration;
class ServerManager;
class QTimer;

namespace Ui
{
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow( Configuration *configuration,
                         ServerManager *serverManager,
                         QWidget *parent = NULL );
    ~MainWindow();

public slots:
    /**
     * @brief Show about dialog.
     */
    void about();

    /**
     * @brief Receives alarms.
     * @param id The server id.
     */
    void alarm( int id );

    /**
     * @brief Show help dialog.
     */
    void help();

    /**
     * @brief Show dialog to manage monitored sites.
     */
    void manage();

    /**
     * @brief Reacts to event of the trayicon.
     * @param reason The reason for the event.
     */
    void trayEvent( const QSystemTrayIcon::ActivationReason &reason );

protected:
        void changeEvent( QEvent *e );
        void closeEvent( QCloseEvent *e );

private:
    Ui::MainWindow *ui;

    Configuration *mConfiguration;
    int mLastAlarmId;
    ServerManager *mServerManager;
    QSystemTrayIcon *mSystemTrayIcon;
    QTimer *mResetTimer;

private slots:
    /**
     * @brief Reset last alarm id.
     */
    void resetLastAlarmId();
};

#endif // MAINWINDOW_H
